package mws;

import lombok.Data;

import static mws.ClientHolder.*;


@Data
public class MessageWrapper {
    private Integer type;
    private String data;
    private boolean isFormatRight = false;

    public MessageWrapper(String msg) {
        if (msg.startsWith("mapperClient:")) {
            msg = msg.substring("mapperClient:".length());
            String[] split = msg.split("-");
            this.type = Integer.valueOf(split[0]);
            if (this.type.equals(ASYNC) || this.type.equals(SYNC) || this.type.equals(DEFAULT)) {
                this.data = split[1];
                isFormatRight = true;
            }
           return;
        }
    }

    public String toString() {
        return "mapperClient:" + type + ":" + data;
    }


}